%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Eigenstates of the LiRb 3Sigma+ potential.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



function EstadoLigado



Constant;

figure(1);



m_au=85*uA/2/mE;									E_au=e0^2/(4*pi*E0)/aB;	%reduced mass & energy in au

aS85=110*aB;

cnst=e0^2/4/pi/E0/aB/2/pi/hP/100/c0;										%conversion a.u. to cm^-1



lvl='(1)3Sigma';		eval(['[Rp,Vp]=LiRbPotential_',lvl(4:length(lvl)),'(lvl);']);	%calls Korek potential



R  =[5.5:.01:50];		[V,Vmorse,Vlngrng]=LiRbStates_Pot(R,lvl);			%Morse and long range potential fitted





%calculates eigenstates



Ges1=-50/cnst;				Ges2=-100/cnst;											%guessed range for eigenvalues

E   =(Ges1+Ges2)/2;

flag=0;

while (1==1)&(flag<20)

	[Rs,Y]=ode45('AM_Molecula_EstadoLigadoLiRb_DGl',R,[1e10 0],[],E,lvl);								%calls DGl

	if Y(length(Rs),2)>0

		Ges2=E;

	else

		Ges1=E;

	end

	[v,a]=LiRbStates_Vib(R,Y(:,2));													%gets vibrational quantum number and scattering length

	Rt   =LiRbStates_Trn(E,lvl);														%gets outer turning point

	scl=min(abs(min(Y(:,2))),abs(max(Y(:,2))))*.1;									%scale factor for wavefunction

	subplot(222),plot(Rp,Vp*cnst,'.r',R,Vmorse*cnst,'g',R,Vlngrng*cnst,'b',R,V*cnst,'k',R,E*cnst,'k',Rs,E*cnst+Y(:,2)/scl,'r')

	set(gca,'xLim',[8 22],'yLim',[1 -.1]*min(V*cnst),'FontSize',16,'LineWidth',1.2);

	xlabel('\fontsize{18}{\itR}   ({\ita}_B)');

	ylabel('\fontsize{18}{\itV}({\itR})   (cm^{-1})');

	text(4,20,'\fontsize{16}(b)')

% 	title(['\fontsize{14}{\itE} = ',num2str(E*cnst),' cm^{-1}       {\itv} = ',num2str(v),...

% 		'       {\itR}_t = ',num2str(Rt),' {\ita}_B      {\itDiverg} = ',num2str(Y(length(Rs),2))])

	pause(.01);

	E=(Ges1+Ges2)/2;

	flag=flag+1;

end



end







function [Rp,Vp] = LiRbPotential_3Sigma(lvl)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Energies versus R (in au) for the lowest 3Sigma+ states of LiRb [Korek00].



M=[

%R(a0)	a3Sigma+	b3Sigma+	c3Sigma+	d3Sigma+	e3Sigma+	f3Sigma+	g3Sigma+

4.50 	-0.302901 	-0.250703 	-0.242653 	-0.216049 	-0.213380 	-0.202678 	-0.198151 

4.60 	-0.306297 	-0.256058 	-0.246192 	-0.220510 	-0.217658 	-0.206925 	-0.202554 

4.80 	-0.312693 	-0.265880 	-0.252826 	-0.228775 	-0.225591 	-0.214826 	-0.210773 

5.00 	-0.318510 	-0.274476 	-0.258810 	-0.236120 	-0.232636 	-0.221866 	-0.218136 

5.20 	-0.323713 	-0.281870 	-0.264094 	-0.242540 	-0.238777 	-0.228020 	-0.224606 

5.40 	-0.328319 	-0.288148 	-0.268679 	-0.248075 	-0.244044 	-0.233331 	-0.230202 

5.60 	-0.332354 	-0.293408 	-0.272581 	-0.252786 	-0.248486 	-0.237843 	-0.234963 

5.80 	-0.335851 	-0.297763 	-0.275840 	-0.256744 	-0.252177 	-0.241634 	-0.238958 

6.20 	-0.341414 	-0.304195 	-0.280641 	-0.262719 	-0.257620 	-0.247339 	-0.244939 

6.60 	-0.345398 	-0.308232 	-0.283545 	-0.266601 	-0.261000 	-0.251028 	-0.248861 

6.80 	-0.346908 	-0.309559 	-0.284428 	-0.267924 	-0.262101 	-0.252267 	-0.250544 

7.00 	-0.348160 	-0.310516 	-0.285000 	-0.268912 	-0.262904 	-0.253172 	-0.252523 

7.20 	-0.349202 	-0.311163 	-0.285311 	-0.269615 	-0.263487 	-0.254535 	-0.253793 

7.40 	-0.350058 	-0.311548 	-0.285402 	-0.270077 	-0.263935 	-0.256314 	-0.254169 

7.60 	-0.350754 	-0.311718 	-0.285313 	-0.270338 	-0.264348 	-0.257772 	-0.254339 

7.80 	-0.351304 	-0.311708 	-0.285076 	-0.270429 	-0.264848 	-0.258815 	-0.254322 

8.00 	-0.351742 	-0.311551 	-0.284728 	-0.270383 	-0.265522 	-0.259414 	-0.254170 

8.20 	-0.352085 	-0.311274 	-0.284295 	-0.270222 	-0.266356 	-0.259597 	-0.253884 

8.40 	-0.352349 	-0.310899 	-0.283798 	-0.269971 	-0.267276 	-0.259474 	-0.253493 

8.60 	-0.352550 	-0.310449 	-0.283267 	-0.269655 	-0.268201 	-0.259153 	-0.253023 

8.80 	-0.352696 	-0.309938 	-0.282721 	-0.269389 	-0.268977 	-0.258691 	-0.252487 

9.00 	-0.352799 	-0.309381 	-0.282179 	-0.269983 	-0.268776 	-0.258153 	-0.251900 

9.20 	-0.352867 	-0.308792 	-0.281668 	-0.270702 	-0.268332 	-0.257564 	-0.251285 

9.40 	-0.352906 	-0.308179 	-0.281199 	-0.271323 	-0.267854 	-0.256928 	-0.250639 

9.60 	-0.352924 	-0.307552 	-0.280799 	-0.271828 	-0.267365 	-0.256275 	-0.249991 

9.80 	-0.352923 	-0.306918 	-0.280485 	-0.272206 	-0.266878 	-0.255626 	-0.249356 

10.00 	-0.352907 	-0.306283 	-0.280266 	-0.272446 	-0.266392 	-0.254962 	-0.248726 

10.20 	-0.352881 	-0.305652 	-0.280149 	-0.272553 	-0.265917 	-0.254299 	-0.248115 

10.40 	-0.352846 	-0.305030 	-0.280127 	-0.272537 	-0.265459 	-0.253653 	-0.247537 

10.60 	-0.352806 	-0.304421 	-0.280185 	-0.272418 	-0.265024 	-0.253007 	-0.246991 

10.80 	-0.352761 	-0.303826 	-0.280307 	-0.272219 	-0.264617 	-0.252384 	-0.246489 

11.00 	-0.352713 	-0.303249 	-0.280467 	-0.271962 	-0.264233 	-0.251769 	-0.246026 

11.50 	-0.352588 	-0.301897 	-0.280953 	-0.271190 	-0.263402 	-0.250318 	-0.245083 

12.00 	-0.352465 	-0.300683 	-0.281443 	-0.270363 	-0.262746 	-0.248987 	-0.244426 

12.50 	-0.352349 	-0.299613 	-0.281873 	-0.269566 	-0.262249 	-0.247792 	-0.244023 

13.00 	-0.352246 	-0.298685 	-0.282230 	-0.268832 	-0.261884 	-0.246743 	-0.243808 

13.50 	-0.352156 	-0.297892 	-0.282518 	-0.268170 	-0.261621 	-0.245869 	-0.243690 

14.00 	-0.352078 	-0.297218 	-0.282745 	-0.267576 	-0.261432 	-0.245236 	-0.243524 

14.50 	-0.352012 	-0.296650 	-0.282925 	-0.267044 	-0.261296 	-0.244928 	-0.243170 

15.00 	-0.351955 	-0.296172 	-0.283065 	-0.266570 	-0.261196 	-0.244874 	-0.242646 

15.50 	-0.351909 	-0.295775 	-0.283177 	-0.266149 	-0.261119 	-0.244927 	-0.242070 

16.00 	-0.351869 	-0.295445 	-0.283264 	-0.265774 	-0.261056 	-0.245006 	-0.241490 

16.50 	-0.351836 	-0.295169 	-0.283336 	-0.265443 	-0.261002 	-0.245082 	-0.240930 

17.00 	-0.351808 	-0.294936 	-0.283393 	-0.265151 	-0.260949 	-0.245139 	-0.240390 

17.50 	-0.351785 	-0.294741 	-0.283440 	-0.264897 	-0.260898 	-0.245175 	-0.239875 

18.00 	-0.351767 	-0.294577 	-0.283478 	-0.264677 	-0.260847 	-0.245184 	-0.239394 

18.50 	-0.351750 	-0.294439 	-0.283512 	-0.264487 	-0.260794 	-0.245170 	-0.238944 

19.00 	-0.351737 	-0.294322 	-0.283532 	-0.264325 	-0.260740 	-0.245134 	-0.238531 

19.50 	-0.351726 	-0.294224 	-0.283557 	-0.264188 	-0.260687 	-0.245084 	-0.238161 

20.00 	-0.351715 	-0.294139 	-0.283576 	-0.264071 	-0.260633 	-0.245016 	-0.237830 

20.50 	-0.351708 	-0.294069 	-0.283602 	-0.263975 	-0.260582 	-0.244938 	-0.237542 

21.00 	-0.351701 	-0.294008 	-0.283619 	-0.263893 	-0.260531 	-0.244848 	-0.237288 

21.50 	-0.351695 	-0.293957 	-0.283634 	-0.263825 	-0.260484 	-0.244752 	-0.237066 

22.00 	-0.351690 	-0.293913 	-0.283645 	-0.263767 	-0.260439 	-0.244651 	-0.236870 

22.50 	-0.351686 	-0.293875 	-0.283656 	-0.263720 	-0.260399 	-0.244554 	-0.236697 

23.00 	-0.351683 	-0.293843 	-0.283666 	-0.263681 	-0.260363 	-0.244455 	-0.236540 

23.50 	-0.351679 	-0.293815 	-0.283674 	-0.263647 	-0.260328 	-0.244356 	-0.236390 

24.00 	-0.351676 	-0.293791 	-0.283681 	-0.263620 	-0.260298 	-0.244261 	-0.236259 

24.50 	-0.351674 	-0.293771 	-0.283688 	-0.263597 	-0.260271 	-0.244170 	-0.236131 

25.00 	-0.351672 	-0.293753 	-0.283693 	-0.263578 	-0.260247 	-0.244083 	-0.236007 

25.50 	-0.351670 	-0.293737 	-0.283698 	-0.263562 	-0.260226 	-0.244001 	-0.235899 

26.00 	-0.351668 	-0.293724 	-0.283702 	-0.263548 	-0.260207 	-0.243925 	-0.235793 

26.50 	-0.351667 	-0.293713 	-0.283707 	-0.263537 	-0.260191 	-0.243856 	-0.235693 

27.00 	-0.351665 	-0.293702 	-0.283710 	-0.263526 	-0.260176 	-0.243790 	-0.235595 

27.50 	-0.351663 	-0.293693 	-0.283713 	-0.263518 	-0.260163 	-0.243730 	-0.235499 

28.00 	-0.351663 	-0.293685 	-0.283716 	-0.263512 	-0.260152 	-0.243677 	-0.235415 

28.50 	-0.351661 	-0.293678 	-0.283718 	-0.263505 	-0.260142 	-0.243627 	-0.235330 

29.00 	-0.351661 	-0.293672 	-0.283720 	-0.263500 	-0.260134 	-0.243583 	-0.235255 

29.50 	-0.351659 	-0.293666 	-0.283722 	-0.263495 	-0.260126 	-0.243542 	-0.235181 

30.00 	-0.351659 	-0.293662 	-0.283724 	-0.263492 	-0.260119 	-0.243507 	-0.235115 

31.00 	-0.351657 	-0.293653 	-0.283726 	-0.263485 	-0.260108 	-0.243445 	-0.234993 

32.00 	-0.351656 	-0.293646 	-0.283728 	-0.263480 	-0.260099 	-0.243396 	-0.234892 

33.00 	-0.351656 	-0.293641 	-0.283731 	-0.263477 	-0.260093 	-0.243358 	-0.234812 

34.00 	-0.351655 	-0.293637 	-0.283732 	-0.263468 	-0.260085 	-0.243324 	-0.234735 

35.00 	-0.351654 	-0.293633 	-0.283733 	-0.263472 	-0.260082 	-0.243304 	-0.234696 

36.00 	-0.351654 	-0.293631 	-0.283735 	-0.263470 	-0.260079 	-0.243286 	-0.234656 

37.00 	-0.351654 	-0.293629 	-0.283736 	-0.263466 	-0.260076 	-0.243271 	-0.234622 

38.00 	-0.351653 	-0.293626 	-0.283735 	-0.263462 	-0.260073 	-0.243257 	-0.234593 

39.00 	-0.351653 	-0.293625 	-0.283736 	-0.263467 	-0.260072 	-0.243252 	-0.234578 

40.00 	-0.351653 	-0.293623 	-0.283737 	-0.263465 	-0.260071 	-0.243245 	-0.234564 

41.00 	-0.351652 	-0.293622 	-0.283738 	-0.263465 	-0.260070 	-0.243241 	-0.234552 

42.00 	-0.351652 	-0.293622 	-0.283738 	-0.263465 	-0.260069 	-0.243236 	-0.234543 

43.00 	-0.351651 	-0.293620 	-0.283738 	-0.263463 	-0.260067 	-0.243231 	-0.234535 

44.00 	-0.351651 	-0.293619 	-0.283738 	-0.263463 	-0.260066 	-0.243225 	-0.234529 

45.00 	-0.351651 	-0.293619 	-0.283738 	-0.263464 	-0.260066 	-0.243227 	-0.234526 

46.00 	-0.351651 	-0.293618 	-0.283738 	-0.263464 	-0.260065 	-0.243225 	-0.234522 

47.00 	-0.351651 	-0.293618 	-0.283738 	-0.263463 	-0.260065 	-0.243222 	-0.234520 

48.00 	-0.351651 	-0.293618 	-0.283739 	-0.263463 	-0.260065 	-0.243221 	-0.234519 

49.00 	-0.351651 	-0.293617 	-0.283738 	-0.263463 	-0.260064 	-0.243220 	-0.234517 

50.00 	-0.351651 	-0.293617 	-0.283739 	-0.263463 	-0.260064 	-0.243219 	-0.234515 

55.00 	-0.351651 	-0.293616 	-0.283739 	-0.263461 	-0.260063 	-0.243215 	-0.234511 

60.00 	-0.351650 	-0.293615 	-0.283739 	-0.263462 	-0.260062 	-0.243213 	-0.234509 

70.00 	-0.351650 	-0.293614 	-0.283739 	-0.263462 	-0.260061 	-0.243211 	-0.234508 

];



Rp  =M(:,1);

Vp  =M(:,str2num(lvl(2))+1)-M(length(M),str2num(lvl(2))+1);

end



function [V,Vmorse,Vlngrng] = LiRbStates_Pot(R,lvl)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% LiRb potentials, adapts the potential in atomic units.



	Constant;

	cnst=e0^2/4/pi/E0/aB/2/pi/hP/100/c0;													%conversion a.u. to cm^-1



	[Rm,Dm,Bm,Rt,C6,C8,C10]=LiRbStates_Par(R,lvl);										%gets van der Waals parameters



	Vmorse=Dm/cnst*((1-exp(-(R-Rm)/Bm)).^2-1);											%Morse part of the potential in a.u.



	Vlngrng=-(C6./R.^6)-(C8./R.^8)-(C10./R.^10);											%long range part of the potential in a.u.



	F=exp(-(R/Rt).^10);																		%join potentials

	V=Vmorse.*F + Vlngrng.*(1-F);

end



function d_Y = LiRbStates_DGl(R,Y,flag,Ej,lvl)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Eigenstates of a potential, DGl routine.



	Constant;

	fctr=2*2*uA/(1/6+1/87)/mE;



	d_Y=[fctr*(LiRbStates_Pot(R,lvl)-Ej)*Y(2) ; Y(1)];

end



function [v,a] = LiRbStates_Vib(R,Psi)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% LiRb potential, counts vibrational quantum number and determines scattering length.



%counts vibrational quantum number

	v=0;

	for j=2:length(Psi)

		if Psi(j)*Psi(j-1)<0

			v=v+1;

		end

	end



%determines scattering length 

	for j=length(Psi):-1:2

		if Psi(j)*Psi(j-1)<0

			a=R(j);

			break;

		end

	end

end



function Rt = LiRbStates_Trn(E,lvl)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% LiRb potential, finds outer turning point.



	Rx=[.01:.01:100];

	[V,Vmorse,Vlngrng]=LiRbStates_Pot(Rx,lvl);

	[Vmin,Imin]=min(V);

	V =V (Rx>Rx(Imin));

	Rx=Rx(Rx>Rx(Imin));

	[Vmin,Imin]=min((E-V).^2);

	Rt=Rx(Imin);

end



function [Rm,Dm,Bm,Rt,C6,C8,C10] = LiRbStates_Par(R,lvl)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% LiRb potentials, gets van der Waals parameters,

%  Rm : center of exchange potential			in aB

%  Dm : potential depth							in 1/cm

%  Bm : width of exchange potential			in aB

%  Rt : short-to-long range connection point	in aB

%  C6 : van der Waals coefficient				in aB^6 

%  Te : potential depth							in 1/cm

%  Re : location of potential minimum			in Angs

%  we :											in 1/cm

%  Be : rotational constant						in 1/cm

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



if     sum(lvl(1:6)=='(1)1Si')==6 wch=1;

elseif sum(lvl(1:6)=='(2)1Si')==6 wch=2;

elseif sum(lvl(1:6)=='(3)1Si')==6 wch=3;

elseif sum(lvl(1:6)=='(1)3Si')==6 wch=4;

elseif sum(lvl(1:6)=='(2)3Si')==6 wch=5;

elseif sum(lvl(1:6)=='(3)3Si')==6 wch=6;

elseif sum(lvl(1:6)=='(1)1Pi')==6 wch=7;

elseif sum(lvl(1:6)=='(2)1Pi')==6 wch=8;

elseif sum(lvl(1:6)=='(1)3Pi')==6 wch=9;

elseif sum(lvl(1:6)=='(2)3Pi')==6 wch=10;

end



Pa=[																														%[Korek00 & Marinescu99]]

%Rm		Dm		Bm		Rt		C6			C8			C10			Te		Re		we		Be

6.4		4700	2.3		9.6		2545		2.34e5		2.61e7		0		3.43	194.0	.220		%(1)1Sigma+	X	%[Derevianko01 & 03]

7.84	7087	4.02	16.0	2.6744e4	2.8089e6	0			11639	4.138	119.6	.152		%(2)1Sigma+	A	

7.9    3490	3.0    15.8	-1.6506e4	1.8187e6	0			17438	4.257	113.0	.144		%(3)1Sigma+	C

9.65	279		2.5		20		3015		7.6e5		7e7			5678	5.126	41.2	.100		%(1)3Sigma+	a

7.64	3941	2.94	24.1	2.6744e4	2.8089e6	0			14719	4.064	129.9	.157		%(2)3Sigma+	c

7.35	370		1.0		16.6	-1.6506e4	1.8187e6	0			0		0		0		0			%(3)3Sigma+

7.35	1429	2.13	13.7	9.4312e3	1.7135e5	0			17205	3.813	140.5	.179		%(1)1Pi		B

7.8    1481	2.4		10.9	-2.5677e3	4.1208e5	0			19201	4.101	141.7	.155		%(2)1Pi		D

6.14	8426	2.63	11.7	9.4312e3	1.7135e5	0			10233	3.348	191.7	.232		%(1)3Pi		b

7.74	1383	2.30	13.6	-2.5677e3	4.1208e5	0			19484	4.115	39.4	.160		%(2)3Pi

];



Rm=Pa(wch,1);																							%in aB

Dm=Pa(wch,2);																							%in a.u.

Bm=Pa(wch,3);																							%in 1/aB

Rt=Pa(wch,4);																							%in 1/aB

C6 =Pa(wch,5);																						%in aB^6

C8 =Pa(wch,6);																						%in aB^8

	C10=Pa(wch,7);																						%in aB^10



	Po=[																														%[Marinescu97]

%C5			C6			C8			C10

	0			2.7415e4	8.6940e6	3.4006e9															%2S-6S 1,3Sigma+

	0			1.1736e5	8.6022e6	2.5892e9															%3S-5S 1,3Sigma+

	0			1.5217e4	5.8713e6	0 																	%2S-4D	1,3Sigma+

	0			1.3195e4	1.5770e6	0																	%2S-4D	1,3Pi	

	0			7.1308e3	-1.5547e5	0																	%2S-4D	1,3Delta

	0			2.6838e4	3.2636e7	0																	%3D-5S	1,3Sigma+

	0			2.4318e4	1.2976e7	0																	%3D-5S	1,3Pi	

	0			1.6758e4	6.8198e5	0																	%3D-5S	1,3Delta

	-3.8417e2	6.5618e3	-1.8430e6	0																	%2P-5P	1,3Delta

	1.5367e3	6.1659e3	1.7324e6	0																	%2P-5P	1,3Pi

	0			1.1244e4	-2.5382e6	0																	%2P-5P	1,3Pi

	0			4.0227e3	-2.3540e4	0																	%2P-5P	1,3Sigma-

	0			1.0107e4	-3.4418e6	0																	%2P-5P	1,3Sigma+

	-2.3050e3	-9.0214e4	3.9927e6	0																	%2P-5P	1,3Sigma+

	];

end

